/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			fileimpl.h
  \date			Dec 2012
  \author		TNick

  \brief		Contains the definition for FileImpl class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __FILEIMPL_INC__
#define __FILEIMPL_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<memtrack.h>
#include	<cpg/actions/editorbase.h>
#include	<QObject>
#include	<ui_file.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

class	ActionsHost;
class	QCloseEvent;
class	QMenu;
class	QToolBar;

/**
*	@brief
*/
class FileImpl				: public QObject, public MemTrack	{
	Q_OBJECT
	BBM_TRACK( FileImpl )

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/**
	*	@brief
	*/
	Ui::File				ui_;


	/**
	*	@brief	the host
	*/
	ActionsHost *			host_;


	/**
	*	@brief	number of recent files to save
	*/
	int						rcnt_f_count;


	/**
	*	@brief	recent files list
	*/
	QList<QString>			rcnt_f;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	FileImpl			( QObject * parent = NULL );


	/**
	*	@brief	destructor;
	*/
	virtual				~FileImpl		( void );


	/**
	*	@brief	initialisation
	*/
	bool				init			( ActionsHost * host );


	/**
	*	@brief	termination
	*/
	void				end				( void );


	/**
	*	@brief	inserts the actions in the menu
	*/
	void				initMenu		( QMenu * menu );


	/**
	*	@brief	inserts the actions in the toolbar
	*/
	void				initToolbar		( QToolBar * menu );



signals:


	/**
	*	@brief	emited when application should exit
	*/
	void				appEndReq					( void );


	/**
	*	@brief	emited when a document editor is created
	*/
	void				editorCreated				( EditorBase * ed );


	/**
	*	@brief	emited when a document editor should be closed
	*/
	void				editorCloseReq				( EditorBase * ed );


	/**
	*	@brief	emited when a document editor should be saved
	*/
	void				editorSaveReq				( EditorBase * ed );


	/**
	*	@brief	emited when a document editor should be saved
	*/
	void				editorSaveAsReq				( EditorBase * ed );



public slots:


	/**
	*	@brief	initialises the instance to represent a new document
	*/
	void    slot_New            	( void );


	/**
	*	@brief	allows for browsing and loads the file in the instance
	*/
	bool    slot_Open            	( void );


	/**
	*	@brief loads the file in the instance
	*/
	bool    slot_Open            	(
			const QString &		s_file,
			const QString &		loc
			);


	/**
	*	@brief loads the file in the instance
	*/
	bool    slot_Open            	(
			const QString &		s_file
			);


	/**
	*	@brief	high level; saves the document (may call saveAs())
	*/
	void    slot_Save            	( void );


	/**
	*	@brief	shows a dialog allowing to select where to save the document
	*/
	void    slot_SaveAs            	( void );


	/**
	*	@brief	fired when the current editor changes
	*/
	void				activeEditorChanged			( EditorBase * ed );



	/**
	*	@brief	places provided file to the top of recent files list
	*/
	void				addRecentFile				( EditorBase * ed );


private slots:


	/**
	*	@brief	closes current document
	*/
	void    slot_Close            	( void );


	/// used to open a recent file from the menu
	void    slot_RecentFile         ( QAction * p_active );


	/// recreates the list of recent files in the menu
	void    slot_UpdateRcFilesMenu  ( void );



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class FileImpl	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __FILEIMPL_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
